//阻止滑动
$(document).on('touchmove', function (e) {
    e.preventDefault()
});
setTimeout(function () {
    $('.post').css('pointer-events','auto');
    $('.pwd').css('pointer-events','auto');
    $('.forget').css('pointer-events','auto');
},1000)
var rmbUser=window.localStorage.getItem("rmbUser");
var phone=window.localStorage.getItem("phone");
var pwd=window.localStorage.getItem("password");

        if(rmbUser=="true"){
        $("#rmbUser").attr("checked", true);
        $(".phone").val(phone);
        $(".pwd").val(pwd);
    }

//弹框函数
function tip(msg) {
    $(".pop_tip").show().text(msg);
    setTimeout(function () {
        $(".pop_tip").slideUp(1000);
    }, 1000)
}
$('input[type!="checkbox"]').off('focus').on('focus', function () {
    var _self=$(this);
    var ty=$(this).attr('type');
    $('.top_input').show();
    if(ty=='password'){
        $('.top_input input').attr('type',ty);
        $('.top_input input').attr('placeholder','请输入密码')
    }
    $('.top_input input').val(_self.val())
    $('.top_input input').focus();
    $('.top_input input').off('blur').on('blur', function () {
        var v=$('.top_input input').val();
        _self.val(v)
        $('.top_input').hide();
        $('.top_input input').attr('type','text');
        $('.top_input input').attr('placeholder','请输入账号')
    })
    $('.top_input input').off('keydown').on('keydown', function (e) {
        var key= e.which;
        if(key==13){
            var v=$('.top_input input').val();
            _self.val(v)
            $('.top_input').hide();
            $('.top_input input').attr('type','text');
            $('.top_input input').attr('placeholder','请输入账号')
        }
    })
})
$('.forget').off('touchstart').on('touchstart', function () {
        window.location.href='find_pwd.html'
})
//点击登录
$('.post').on('click', function () {
    var phone = $('.phone').val();
    var pwd = $('.pwd').val();

    if($("#rmbUser").is(":checked") == true) {
         window.localStorage.setItem("rmbUser", "true");
         window.localStorage.setItem("phone", phone);
         window.localStorage.setItem("password", pwd);
    }
    else {
         window.localStorage.setItem("rmbUser", "false");
         window.localStorage.setItem("phone", "");
         window.localStorage.setItem("password", "");
    }
    pwd = MD5(pwd + token);
    var pm = {};
    pm.mobile = phone;
    pm.password = pwd;
    getData({url: login, data: pm}, function (data) {
        if (data.msg == "success") {
            tip(data.info);
            window.location.href = "index.html?userid=" + data.userid+'&ID='+data.ID;
            $('top_input').hide()
        } else if (data.msg == "fail") {
            tip(data.info);
        }
    })
});